Reverse a string word by word¶
Write a python class to reverse a string word by word.
Input string:
‘hello .py’
class py_solution:
def reverse_words(self, s):
return ' '.join(reversed(s.split()))
print(py_solution().reverse_words('hello .py')) # .py hello